package us.icitap.cm.business.entities;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import org.eclipse.persistence.annotations.Customizer;

import us.icitap.cm.utils.MyCustomizer;

@Entity
@Customizer(MyCustomizer.class)
@Table(name="PENALTY", schema="MPC")
@IdClass(PenaltyId.class)
public class Penalty implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -5586665214770199099L;

	@Id
	private Integer id;
	
	@Id
	@Column(name="CHARGE_ID", insertable=false, updatable=false)
	private Integer chargeId;
	
	@Id
	@Column(name="PERSON_ID", insertable=false, updatable=false)
	private Integer personId;
	
	@Column(name="MAIN_PENALTY")
	private boolean mainPenalty;
	
	@ManyToOne
	@JoinColumn(name="PENALTY_TYPE_ID")
	private PenaltyType penaltyType;
	
	private Integer length;
	
	@Enumerated(EnumType.STRING)
	@Column(name="PERIOD_UNIT", length=1)
	private PeriodUnitEnum periodUnit;
	
	
	private Double value;
	
	@Enumerated(EnumType.STRING)
	@Column(name="VALUE_UNIT", length=6)
	private MonetaryUnitEnum valueUnit;
	
	@Column(length=300)
	private String notes;
	
	@ManyToOne
	@JoinColumns({@JoinColumn(name = "CHARGE_ID", referencedColumnName = "ID"), @JoinColumn(name = "PERSON_ID", referencedColumnName = "PERSON_ID")})
	private Charge charge;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public boolean isMainPenalty() {
		return mainPenalty;
	}

	public void setMainPenalty(boolean mainPenalty) {
		this.mainPenalty = mainPenalty;
	}

	public PenaltyType getPenaltyType() {
		return penaltyType;
	}

	public void setPenaltyType(PenaltyType penaltyType) {
		this.penaltyType = penaltyType;
	}

	public Integer getLength() {
		return length;
	}

	public void setLength(Integer length) {
		this.length = length;
	}

	public PeriodUnitEnum getPeriodUnit() {
		return periodUnit;
	}

	public void setPeriodUnit(PeriodUnitEnum periodUnit) {
		this.periodUnit = periodUnit;
	}

	public Double getValue() {
		return value;
	}

	public void setValue(Double value) {
		this.value = value;
	}

	public MonetaryUnitEnum getValueUnit() {
		return valueUnit;
	}

	public void setValueUnit(MonetaryUnitEnum valueUnit) {
		this.valueUnit = valueUnit;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public Charge getCharge() {
		return charge;
	}

	public void setCharge(Charge charge) {
		this.charge = charge;
	}
	
}
